package org.demo.patten.builder;

import lombok.Data;

/**
 * @author zhuj
 * @date 2025/3/21
 * @apiNote
 */
@Data
public class Person {
    private final String name;
    private final int age;
    private final String phone;
    private final String email;
    private final String address;
    private Person(Builder builder) {
        this.name = builder.name;
        this.age = builder.age;
        this.phone = builder.phone;
        this.email = builder.email;
        this.address = builder.address;
    }
    public static class Builder {
        private String name;
        private int age;
        private String phone;
        private String email;
        private String address;
        public Builder name(String name) { this.name = name; return this; }
        public Builder age(int age) { this.age = age; return this; }
        public Builder phone(String phone) { this.phone = phone; return this; }
        public Builder email(String email) { this.email = email; return this; }
        public Builder address(String address) { this.address = address; return this; }
        public Person build() {
            // 可以在此校验逻辑
            return new Person(this);
        }
    }
}
